package com.yimi.yinhepda.adapter.RecycleAdapter

import android.content.Context
import android.support.v4.content.ContextCompat
import android.view.ViewGroup
import com.yimi.yinhepda.R
import com.pda.ym.base.CommonRecycleAdapter
import com.pda.ym.base.CommonViewHolder
import com.yimi.yinhepda.entity.response.LoadInfo

/**
 * @author: lj
 * Date: 2020/3/9 14:28
 * Description:分拨自提列表适配器
 */
class FenBoZiTiAdapter(var context: Context?, dataList: MutableList<LoadInfo>?)
    : CommonRecycleAdapter<LoadInfo>(context, dataList, R.layout.item_fenbo_ziti) {

    override fun bindData(holder: CommonViewHolder?, data: LoadInfo?, position: Int) {
        holder?.setText(R.id.tv_waybillNo, data?.waybillNo)
        holder?.setText(R.id.tv_srcPiecesNum, data?.srcPiecesNum.toString())
        holder?.setText(R.id.tv_scanNum, data?.childList?.size.toString())
        if (data?.singBack != null && data.singBackType != null) {
            if (data.singBack!! and (data.singBackType!! == "1")) {
                holder?.setText(R.id.tv_huiDan, "✔")
            } else {
                holder?.setText(R.id.tv_huiDan, "")
            }
        } else {
            holder?.setText(R.id.tv_huiDan, "")
        }

        when (data?.type) {
            0 -> holder?.itemView?.setBackgroundColor(ContextCompat.getColor(context!!, R.color.red))
            1 -> holder?.itemView?.setBackgroundColor(ContextCompat.getColor(context!!, R.color.white))
            2 -> holder?.itemView?.setBackgroundColor(ContextCompat.getColor(context!!, R.color.yellow))
            3 -> holder?.itemView?.setBackgroundColor(ContextCompat.getColor(context!!, R.color.green))
            else -> holder?.itemView?.setBackgroundColor(ContextCompat.getColor(context!!, R.color.white))
        }

    }
}